package com.hmall.item.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.hmall.item.pojo.Item;


import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface ItemMapper extends BaseMapper<Item> {

    @Select("select count(*) from tb_item ")
    Long findCount();

    @Select("select * from tb_item limit #{index},#{size}")
    List<Item> selectItemByPage(@Param("index")Integer index, @Param("size") Integer size);


    @Update("update tb_item set status = #{status} where id = #{id}")
    void updateStatusById(@Param("id") Long id,@Param("status") Integer status);

    @Delete("delete from tb_item where id = #{id}")
    Integer selectStatusById(Long id);

    void updateStockById(@Param("itemId") Long itemId,@Param("num") Integer num);
}
